<?php
  /**
   * @author EVANDRO DE OLIVEIRA.
   * @category VIEW
   * @package VIEWS/SCRIPTS/PAISES.
   * @since 17/06/2012.
   * @last_update 17/06/2012.
   * @copyright 2012.
   * @version 1.0.
   *
   */
?>
<table border="0" align="center" cellpadding="0" cellspacing="0" class="content-view" id="teste">
  <tr>
    <td id="messenger" colspan="2"><?php echo $this->flashMessage();?></td>
  </tr>
  <tr>
    <td align="left" class="comp-title" style="width: 200px;">CONSULTA DE <?php echo $this->strTitleP?></td>  
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td align="center" colspan="2" style="">
      <table border="0" align="center" cellpadding="0" cellspacing="0" width="100%" class="content-form">
        <tr>
          <td class="space-bottom"></td>
        </tr>
        <tr>
          <td>
            <form name="form_add" method="post" action="" id="form_add">
              <table border="0" align="center" cellpadding="0" cellspacing="0">
                <?php   
                 //Zend_Debug::dump($this->request);
                  foreach($this->arrColunas as $strKey => $arrValues){
                    switch($arrValues['type']){
                      case 'text':
                        $strCampo = $this->input($arrValues['type'], $arrValues['name'], $arrValues['name'], $this->request[$arrValues['name']], false, '', $arrValues['maxlength'], '', "width: {$arrValues['width']}px;");
                      break;
                      
                      case 'textarea':
                        $strCampo = $this->textarea($arrValues['name'], $arrValues['name'], $this->request[$arrValues['name']], false, $arrValues['cols'], $arrValues['rows']);
                      break;
                      
                      case 'db_combo':
                        $strCampo = $this->dbComboBox($arrValues['name'], $arrValues['name'], $arrValues['model'], $arrValues['value'], $arrValues['label'], isset($this->request[$arrValues['value']]) ? $this->request[$arrValues['value']] : '', isset($this->request[$arrValues['label']]) ? $this->request[$arrValues['label']] : 'Selecione', false);
                      break;

                      case 'combo':
                        $strCampo = $this->comboBox($arrValues['name'], $arrValues['name'], $arrValues['options'], $this->request[$arrValues['name']], false);
                      break;
                      
                      case 'date':
                      case 'datetime':
                      	$arrDataValue =  explode(" ", $this->request[$arrValues['name']]);
                      	$strDate = implode('/', array_reverse(explode('-', $arrDataValue[0])));
                        $strCampo = $this->input('text', $arrValues['name'], $arrValues['name'] , $strDate, false, '', '', $arrValues['maxlength'], "width: {$arrValues['width']}px;");
                      break;
                    }

                    ?>
                    <tr>
                      <td align="right" class="label"><?php echo $strKey?>:</td>  
                      <td align="left" class="space-bottom"><?php echo $strCampo?></td>                      
                    </tr>
                    <?php
                  }
                ?>
                <tr>  
                  <td align="center" colspan="3">
                    <?php 
                      echo $this->input('button', 'cancel', 'boton', 'Retornar', true, '', '', '', '', "onclick=\"window.location='" . $this->baseUrlController . "/list'\"");
                    ?>
                  </td>
                </tr>
              </table>
            </form>
          </td>
        </tr>
      </table>
    </td>
  </tr>  
</table>